%% Analysis of Steady-State 25C vs. 37C BarSeq data from Feb. 18 2021 samples
load('EcoliBW25113_Tn_LB_25to37_20200218.mat');
temp = Upshifts_Feb18;
close all;

%% Create plotting arrays
time_25to37C = [-15 10 20 30 40 60 90];
fitness_array_25to37C = [temp.setAIT010218_25to37_15min_B temp.setAIT012218_25to37_10min_B temp.setAIT013218_25to37_20min_B temp.setAIT015218_25to37_30min_B temp.setAIT016218_25to37_40min_B temp.setAIT008218_25to25_60min_B temp.setAIT018218_25to37_90min_B];

% Remove low-read 20min sample
time_25to37C = [-15 10 30 40 60 90];
fitness_array_25to37C = [temp.setAIT010218_25to37_15min_B temp.setAIT012218_25to37_10min_B temp.setAIT015218_25to37_30min_B temp.setAIT016218_25to37_40min_B temp.setAIT008218_25to25_60min_B temp.setAIT018218_25to37_90min_B];

time_25to25C = [-15 0 10 20 30 40 60 90];
fitness_array_25to25C = [temp.setAIT002218_25to25_15min_B temp.setAIT003218_25to25_0min_B temp.setAIT004218_25to25_10min_B temp.setAIT005218_25to25_20min_B temp.setAIT006218_25to25_30min_B temp.setAIT007218_25to25_40min_B temp.setAIT008218_25to25_60min_B temp.setAIT009218_25to25_90min_B];

%% Plot 25to37C data
hits_25to37C = [];

f = figure;
for k=1:size(fitness_array_25to37C,1)
    if mean(abs(fitness_array_25to37C(k,:)))<1
        plot(time_25to37C, fitness_array_25to37C(k,:), 'color', [0.8 0.8 0.8 0.5]);
    else
        plot(time_25to37C, fitness_array_25to37C(k,:), 'r', 'linewidth', 1);
        hits_25to37C = [hits_25to37C; k];
        text(time_25to37C(end), fitness_array_25to37C(k,end), temp.genename(k));
    end
    hold on;
end
ylim([-6 2]);
set(gcf, 'Position', [0 0 400 300]);
set(gca,'fontsize', 20);
box off;
xlabel('Time (min)');
ylabel('Log2 fitness');
exportgraphics(gcf,'Upshift_Feb18_25to37.pdf','ContentType','vector');

%% Plot 25to25C data
hits_25to25C = [];

figure;
for k=1:size(fitness_array_25to25C,1)
    if mean(abs(fitness_array_25to25C(k,:)))<1
        plot(time_25to25C, fitness_array_25to25C(k,:), 'color', [0.8 0.8 0.8 0.5]);
    else
        plot(time_25to25C, fitness_array_25to25C(k,:), 'b', 'linewidth', 1);
        hits_25to25C = [hits_25to25C; k];
        text(time_25to25C(end), fitness_array_25to25C(k,end), temp.genename(k));
    end
    hold on;
end
ylim([-6 2]);
set(gcf, 'Position', [0 0 400 300]);
set(gca,'fontsize', 20);
box off;
xlabel('Time (min)');
ylabel('Log2 fitness');
exportgraphics(gcf,'Upshift_Feb18_25to25.pdf','ContentType','vector');

%% Display hits
disp('25 to 37 hits');
temp.genename(hits_25to37C)
disp('25 to 25 hitsL');
temp.genename(hits_25to25C)